using UnityEngine;
using UnityEngine.Networking;

public class AnimalCharacter : CharacterSystem
{
	public float DamageDirection = 0.5f;

	public float Force = 70f;

	public float StandAttackDuration = 0.5f;

	private float timeTmp;

	public override void Update()
	{
		if (Time.time > timeTmp + StandAttackDuration)
		{
			spdMovAtkMult = 1f;
		}
		base.Update();
	}

	public void DoAttack()
	{
		DoOverlapDamage(base.transform.position + DamageOffset, base.transform.forward * Force, Damage, DamageLength, DamageDirection, NetID, Team);
	}

	public override void PlayMoveAnimation(float magnitude, float side)
	{
		if ((bool)animator)
		{
			if (magnitude > 0.4f)
			{
				animator.SetInteger("StateAnimation", 1);
			}
			else
			{
				animator.SetInteger("StateAnimation", 0);
			}
		}
		base.PlayMoveAnimation(magnitude, side);
	}

	public override void PlayAttackAnimation(bool attacking, int attacktype)
	{
		if ((bool)animator && attacking)
		{
			animator.SetTrigger("Attacking");
			spdMovAtkMult = 0f;
			timeTmp = Time.time;
		}
		base.PlayAttackAnimation(attacking, attacktype);
	}

	public override void SetEnable(bool enable)
	{
		if ((bool)GetComponent<PlayerView>())
		{
			GetComponent<PlayerView>().enabled = enable;
		}
		if ((bool)GetComponent<FPSController>())
		{
			GetComponent<FPSController>().enabled = enable;
		}
		if ((bool)GetComponent<CharacterMotor>())
		{
			GetComponent<CharacterMotor>().enabled = enable;
			GetComponent<CharacterMotor>().Reset();
		}
		if ((bool)GetComponent<CharacterController>())
		{
			GetComponent<CharacterController>().enabled = enable;
		}
		if ((bool)GetComponent<NetworkTransform>())
		{
			GetComponent<NetworkTransform>().enabled = enable;
		}
		if ((bool)GetComponent<CharacterDriver>())
		{
			GetComponent<CharacterDriver>().NoVehicle();
		}
		base.SetEnable(enable);
	}

	public override void OnThisThingDead()
	{
		if (NetID != -1)
		{
			RemoveCharacterData();
		}
		if ((bool)UnitZ.NetworkGameplay.scoreManager)
		{
			UnitZ.NetworkGameplay.scoreManager.AddDead(1, NetID);
			if (NetID != LastHitByID)
			{
				UnitZ.NetworkGameplay.scoreManager.AddScore(1, LastHitByID);
			}
		}
		if (base.isServer)
		{
			ItemDropAfterDead component = GetComponent<ItemDropAfterDead>();
			if ((bool)component)
			{
				component.DropItem();
			}
		}
		base.OnThisThingDead();
	}

	private void UNetVersion()
	{
	}

	public override bool OnSerialize(NetworkWriter writer, bool forceAll)
	{
		bool flag = base.OnSerialize(writer, forceAll);
		bool flag2 = default(bool);
		return flag2 | flag;
	}

	public override void OnDeserialize(NetworkReader reader, bool initialState)
	{
		base.OnDeserialize(reader, initialState);
	}
}
